﻿using NUnit.Framework;
using Validate.Extensions;

namespace Validate.UnitTests
{
    [TestFixture]
    public class ValidatorTests_NotBetween
    {
        [Test]
        public void ShouldPassNotBetween()
        {   
            Assert.IsTrue(3.Validate().IsNotBetween(i => i, 4, 6, "5 is between 4 and 6").IsValid);
            Assert.IsTrue(7.Validate().IsNotBetween(i => i, 4, 6, "5 is between 4 and 6").IsValid);
        }

        [Test]
        public void ShouldFailNotBetween()
        {
            Assert.IsFalse(5.Validate().IsNotBetween(i => i, 4, 6, "5 is between 4 and 6").IsValid);
            Assert.IsFalse(4.Validate().IsNotBetween(i => i, 4, 6, "4 is between 4 and 6").IsValid);
            Assert.IsFalse(6.Validate().IsNotBetween(i => i, 4, 6, "6 is between 4 and 6").IsValid);
        }

        [Test]
        public void ShouldBeAbleToVerifyAutoGeneratedValidationMessage1()
        {
            var person = new Person { Name = "Some Name", Age = 26, Goals = 100 };
            var validator = person.Validate(new ValidationOptions { StopOnFirstError = false })
                .IsNotBetween(v => v.Age, 25, 30)
                .IsNotBetween(v => v.Goals, 100, 150);
            Assert.That(validator.Errors[0].Message, Is.EqualTo("Person.Age should not be between \"25\" and \"30\"."));
            Assert.That(validator.Errors[1].Message, Is.EqualTo("Person.Goals should not be between \"100\" and \"150\"."));
        }
    }
}